#include<bits/stdc++.h>
using namespace std;
const int PRE = 2e7+10,MOD = 1e9+7;
int m;
long long n;
int k;
int minP[PRE];
int idk[PRE];
int mu[PRE];
int sigk[PRE];
int pa[PRE];
int muidk[PRE];
int qpow(int x,int p){
    int res = 1;
    while(p){
        if(p & 1){
            res = 1ll*res*x%MOD; 
        }
        x = 1ll*x*x%MOD;
        p >>= 1;
    }
    return res;
}
const int K = 7e3+10;
int jc[K],jc_1[K];
int w[K];
void init(){
    vector<int> p;
    mu[1] = 1;
    sigk[1] = 1;
    idk[1] = 1;
    for(int i = 2;i<=m;i++){
        if(!minP[i]){
            minP[i] = i;
            idk[i] = qpow(i,k);
            mu[i] = MOD-1;
            sigk[i] = (1 + idk[i])%MOD;
            pa[i] = i;
            p.push_back(i);
        }
        for(int j = 0;1ll*p[j] * i <= m && minP[i] != p[j];j++){
            minP[i * p[j]] = p[j];
            idk[i * p[j]] = 1ll*idk[p[j]]*idk[i]%MOD;
            mu[i * p[j]] = MOD-mu[i];
            sigk[i * p[j]] = 1ll*sigk[i]*sigk[p[j]]%MOD;
            pa[i * p[j]] = p[j];
        }
        if(1ll*i*minP[i] <= m){
            minP[i * minP[i]] = minP[i];
            idk[i * minP[i]] = 1ll*idk[i]*idk[minP[i]]%MOD;
            pa[i * minP[i]] = pa[i] * minP[i]; 
            sigk[i * minP[i]] = (sigk[i] + 1ll*sigk[i/pa[i]]*idk[pa[i]*minP[i]]%MOD)%MOD;
        }
    }
    for(int i = 1;i<=m;i++){
        muidk[i] = (muidk[i - 1] + 1ll*mu[i]%MOD*idk[i]%MOD)%MOD;
        idk[i] = (idk[i] + idk[i - 1])%MOD;
        mu[i] = (mu[i - 1] + mu[i])%MOD;
        sigk[i] = (sigk[i] + sigk[i - 1])%MOD;
    }
    for(int i = 1;i<=k + 10;i++){
        idk[i] = (qpow(i,k) + idk[i - 1])%MOD;
    }
    jc[0] = 1;
    for(int i = 1;i <= k+10;i++){
        jc[i] = 1ll*jc[i - 1]*i%MOD;
    }
    jc_1[k+10] = qpow(jc[k+10],MOD - 2);
    for(int i = k + 9;i >= 1;i--){
        jc_1[i] = 1ll*jc_1[i + 1]*(i + 1)%MOD;
    }
    jc_1[0] = 1;
    for(int i = 1;i<=k + 1;i++){
        if((k+1 - i) % 2 == 0){
            w[i] = 1ll*jc_1[i]*jc_1[k+1 - i]%MOD*idk[i]%MOD;
        }else{
            w[i] = (MOD - 1ll*jc_1[i]*jc_1[k+1 - i]%MOD*idk[i]%MOD)%MOD;
        }
    }
}
unordered_map<int,int> imp;
int query_sum_idk(int p){
    if(p <= max(m,k + 1)){
        return idk[p];
    }
    if(imp.count(p)){
        return imp[p];
    }
    vector<int> prebuild(k + 3,1);
    for(int i = 0;i <= k + 1;i++){
        prebuild[i] = p - i;
    }
    for(int i = k;i >= 0;i--){
        prebuild[i] = 1ll*prebuild[i + 1]*prebuild[i]%MOD;
    }
    int res = 0;
    int buf = 1;
    for(int i = 1;i<=k + 1;i++){
        buf = 1ll*buf*(p - i + 1)%MOD;
        res = (res + 1ll*w[i]*buf%MOD*prebuild[i + 1]%MOD)%MOD;
    }
    return res;
}
unordered_map<long long,int> mmp;
int query_sum_mu(long long p){
    if(p <= m){
        return mu[p];
    }
    if(mmp.count(p)){
        return mmp[p];
    }
    long long r = 0;
    int res = 1;
    for(long long l = 2;l <= p;l = r + 1){
        r = min(p/(p/l),p);
        res = (res + MOD - 1ll*(r - l + 1)*query_sum_mu(p/l)%MOD)%MOD;
    }
    mmp[p] = res;
    return res;
}
unordered_map<long long,int> mimp;
int query_sum_muidk(long long p){
    if(p <= m){
        return muidk[p];
    }
    if(mimp.count(p)){
        return mimp[p];
    }
    int res = 1;
    long long r = 0;
    for(long long l = 2;l <= p;l = r + 1){
        r = min(p/(p/l),p);
        res = (res + MOD - 1ll*(query_sum_idk(r%MOD) - query_sum_idk((l - 1)%MOD) + MOD)*query_sum_muidk(p/l)%MOD)%MOD;
    }
    mimp[p] = res;
    return res;
}
unordered_map<long long,int> smp;
int query_sum_sigk(long long p){
    if(p <= m){
        return sigk[p];
    }
    if(smp.count(p)){
        return smp[p];
    }
    int res = query_sum_idk(p%MOD);
    long long r = 0;
    for(long long l = 2;l <= p;l = r + 1){
        r = min(p/(p/l),p);
        res =(res + MOD - 1ll*(query_sum_mu(r) - query_sum_mu(l - 1) + MOD)%MOD*query_sum_sigk(p/l)%MOD)%MOD;
    }
    smp[p] = res;
    return res;
}
int main(){
    cin>>n>>k;
    m = (int)pow(n*4,2.0/3);
    init();
    long long r = 0;
    int res = 0;
    for(long long l = 1;l <= n;l = r + 1){
        r = min(n/(n/l),n);
        int v2 = query_sum_sigk(n/l);
        res = (res + 1ll*(query_sum_muidk(r) - query_sum_muidk(l - 1) + MOD)%MOD*v2%MOD*v2%MOD)%MOD;
    }
    cout<<res<<'\n';
}